/**
* Android Campus Maps
* http://code.google.com/p/vuphone/
*
* @author Adam Albright
* @date Oct 12, 2009
*
* Copyright 2009 VUPhone Team
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package edu.vanderbilt.vuphone.android.campusmaps;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
import android.content.Context;
import android.location.Address;
import android.location.Geocoder;
import com.google.android.maps.GeoPoint;
public class GeoCode {
public static String getAddress(Context context, GeoPoint p) {
Geocoder geoCoder = new Geocoder(context, Locale.getDefault());
try {
List<Address> addresses = geoCoder.getFromLocation(p
.getLatitudeE6() / 1E6, p.getLongitudeE6() / 1E6, 1);
StringBuilder add = new StringBuilder();
if (addresses.size() > 0) {
for (int i = 0; i < addresses.get(0).getMaxAddressLineIndex(); i++)
add.append(addresses.get(0).getAddressLine(i));
add.append("\n");
}
return add.toString();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}